package com.freak.wanandroid.model.search.detail;

import com.freak.httpmanager.callback.SubscriberCallBack;
import com.freak.wanandroid.base.repository.BaseRepository;
import com.freak.wanandroid.bean.SearchDetailBean;
import com.freak.wanandroid.net.HttpResultFunc;

import io.reactivex.rxjava3.core.Observable;

/**
 * Created by 74099 on 2018/9/6.
 */

public class SearchDetailRepository extends BaseRepository {



    public void getSearchDetail(int page,String k,SubscriberCallBack<SearchDetailBean> observer) {
        Observable observable= mApiService.doSearch(page,k).map(new HttpResultFunc<SearchDetailBean>());
        addSubscription(observable,observer);
    }


    /**
     * 收藏文章
     */
    public void doCollect(int id,SubscriberCallBack<String> observer) {
        Observable observable = mApiService.doCollect(id).map(new HttpResultFunc<String>());
        addSubscription(observable, observer);
    }
    /**
     * 文章列表中取消收藏
     *
     * @param id
     */
    public void doCancelCollect(int id,SubscriberCallBack<String> observer) {
        Observable observable = mApiService.doCancelCollect(id).map(new HttpResultFunc<String>());
        addSubscription(observable, observer);
    }
}
